//
//  SLCommonOptionChooseCell.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/22.
//

#import "SLCommonOptionChooseCell.h"
#import <YYKit.h>
#import <Masonry.h>

@implementation SLCommonOptionChooseCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.bgView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.check];
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.contentView).inset(20);
            make.top.bottom.equalTo(self.contentView).inset(10);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgView).inset(20);
            make.centerY.equalTo(self.bgView);
        }];
        [self.check mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.bgView);
            make.top.bottom.equalTo(self.bgView);
            make.width.mas_equalTo(self.check.mas_height);
        }];
    }
    return self;
}


- (void)setIsSelected:(BOOL)isSelected {
    _isSelected = isSelected;
    if (isSelected) {
        self.check.image = [UIImage imageNamed:@"icon_option_select"];
    } else {
        self.check.image = [UIImage imageNamed:@"icon_option_normal"];
    }
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.layer.cornerRadius = 15;
        _bgView.layer.borderColor = UIColorHex(#1B1B1B).CGColor;
        _bgView.layer.borderWidth = 1.5;
    }
    return _bgView;
}
- (UIView *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.textColor = UIColorHex(#1B1B1B);
        _titleLabel.font = aspectBoldFont(14);
    }
    return _titleLabel;
}
- (UIImageView *)check {
    if (!_check) {
        _check = [UIImageView new];
        _check.layer.cornerRadius = 15;
    }
    return _check;
}

@end
